<?php 
class Application_Form_Actualite  extends Twitter_Bootstrap_Form_Horizontal
{
	 


	public function init()
	{
		$this->setMethod("post");
		
		$decorators=array(
    			array('ViewHelper', array('tag'   => 'div', "class"=>"controls")),
    			array('Label' , array(  "class"=>"control-label")),
    			'Errors',
    			new Zend_Form_Decorator_HtmlTag(array(
    					'tag'   => 'div', "class"=>"control-group"
    			))
    	);
		 
		$translate = Zend_Registry::get('Zend_Translate');
		$translate->setLocale('fr');
		
		
		$titreact = new Zend_Form_Element_Text('titreact');
		$titreact->setRequired(true)
		->setAttrib("class", "input-large");
		$titreact->setLabel("Titre: ");
		$titreact->setDecorators($decorators);
		$this->addElement($titreact);
		
		
		
		$descact = new Zend_Form_Element_Textarea('descact');
		$descact->setAttrib('rows', 4);
		$descact->setAttrib('cols', 30);
		$descact->setLabel("Description: ");
		$act_model=new Application_Model_DbTable_Session();
		$act_record=$act_model->fetchAll();
		
		if($act_record){
			$respons=$act_record->toArray();
			foreach ($respons as $value){
				$descact->setAttrib($value['id_session'],$value['titre'] );
			}
		}
		$descact->setDecorators($decorators);
		$descact->setRequired(true);
		$this->addElement($descact);
		
		
		
		$imgact = new Zend_Form_Element_File('imgact');
		$imgact->setDestination(APPLICATION_PATH .'/modules/c2i/upload');
		// ensure only 1 file
		$imgact->addValidator('Count', true, 1);
		// limit to 100K
		
		$imgact->addValidator('Size', true, 102400);
		
		// only JPEG, PNG, and GIFs
		//$imgact->setDecorators($decorators);
		$imgact->addValidator('Extension', true, 'CSV,csv,txt,png,jpg,pdf,doc,docx');
		$this->setAttrib('enctype', 'multipart/form-data');
		$this->addElement($imgact, 'imgact'); 
		
		 
		 
		
		$sendBt = new Zend_Form_Element_Submit('enregistrer');
		$sendBt->setLabel('Enregistrer');
		$sendBt->setAttrib('class', 'btn');
		$this->addElement($sendBt);
		
		$annuler = new Zend_Form_Element_Button('annuler');
		$annuler->setLabel('Annuler');
		$annuler->setAttrib('class', 'btn');
		$this->addElement($annuler);
		
		$sendBt->setDecorators(array('ViewHelper'));
		$annuler->setDecorators(array('ViewHelper'));
		
	}
}
